package com.gustuy.chat;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.InetSocketAddress;

public class Udpsender {
    public static void main(String[] args)throws Exception {
        int port=9999;
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        DatagramSocket socket=new DatagramSocket();
        while (true){
            String data=reader.readLine();
            byte[] datas=data.getBytes();
            DatagramPacket packet=new DatagramPacket(datas,0,datas.length,new InetSocketAddress("localhost",9999));
            socket.send(packet);
            if(data.equals("bye"))
                break;
        }
        socket.close();

    }
}
